﻿'
' Will Strohl (will.strohl@gmail.com)
' http://www.willstrohl.com
'
'Copyright (c) 2011, Will Strohl
'All rights reserved.
'
'Redistribution and use in source and binary forms, with or without modification, are 
'permitted provided that the following conditions are met:
'
'Redistributions of source code must retain the above copyright notice, this list of 
'conditions and the following disclaimer.
'
'Redistributions in binary form must reproduce the above copyright notice, this list 
'of conditions and the following disclaimer in the documentation and/or other 
'materials provided with the distribution.
'
'Neither the name of Will Strohl nor the names of its contributors may be 
'used to endorse or promote products derived from this software without specific prior 
'written permission.
'
'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
'EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
'OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
'SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
'TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
'BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
'ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
'DAMAGE.
'

Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions

Imports WillStrohl.Modules.CodeCamp.CodeCampInfoMembers

Namespace WillStrohl.Modules.CodeCamp

    <Serializable()> _
    Public NotInheritable Class CodeCampInfo
        Implements ICodeCampInfo, IHydratable

#Region " Private Members "

        Private p_AltText As String = Null.NullString
        Private p_BeginDate As DateTime = Null.NullDate
        Private p_CodeCampId As Integer = Null.NullInteger
        Private p_CreatedByDate As DateTime = Null.NullDate
        Private p_CreatedByUser As Integer = Null.NullInteger
        Private p_Description As String = Null.NullString
        Private p_EndDate As DateTime = Null.NullDate
        Private p_EventFull As Boolean = Null.NullBoolean
        Private p_IconFile As String = Null.NullString
        Private p_MaximumCapacity As Integer = Null.NullInteger
        Private p_ModuleId As Integer = Null.NullInteger
        Private p_NumberRegistered As Integer = Null.NullInteger
        Private p_RegistrationActive As Boolean = Null.NullBoolean
        Private p_RoleName As String = Null.NullString
        Private p_ShowAuthor As Boolean = Null.NullBoolean
        Private p_ShowMicrosoftMVP As Boolean = Null.NullBoolean
        Private p_ShowShirtSize As Boolean = Null.NullBoolean
        Private p_Title As String = Null.NullString
        Private p_WaitListRoleName As String = Null.NullString

#End Region

#Region " Public Properties "

        Public Property AltText() As String Implements ICodeCampInfo.AltText
            Get
                Return Me.p_AltText
            End Get
            Set(ByVal value As String)
                Me.p_AltText = value
            End Set
        End Property

        Public Property BeginDate() As DateTime Implements ICodeCampInfo.BeginDate
            Get
                Return Me.p_BeginDate
            End Get
            Set(ByVal value As DateTime)
                Me.p_BeginDate = value
            End Set
        End Property

        Public Property CodeCampId() As Integer Implements ICodeCampInfo.CodeCampId
            Get
                Return Me.p_CodeCampId
            End Get
            Set(ByVal value As Integer)
                Me.p_CodeCampId = value
            End Set
        End Property

        Public Property CreatedByDate() As DateTime Implements ICodeCampInfo.CreatedByDate
            Get
                Return Me.p_CreatedByDate
            End Get
            Set(ByVal value As DateTime)
                Me.p_CreatedByDate = value
            End Set
        End Property

        Public Property CreatedByUser() As Integer Implements ICodeCampInfo.CreatedByUser
            Get
                Return Me.p_CreatedByUser
            End Get
            Set(ByVal value As Integer)
                Me.p_CreatedByUser = value
            End Set
        End Property

        Public Property Description() As String Implements ICodeCampInfo.Description
            Get
                Return Me.p_Description
            End Get
            Set(ByVal value As String)
                Me.p_Description = value
            End Set
        End Property

        Public Property EndDate() As DateTime Implements ICodeCampInfo.EndDate
            Get
                Return Me.p_EndDate
            End Get
            Set(ByVal value As DateTime)
                Me.p_EndDate = value
            End Set
        End Property

        Public Property EventFull() As Boolean Implements ICodeCampInfo.EventFull
            Get
                Return Me.p_EventFull
            End Get
            Set(ByVal value As Boolean)
                Me.p_EventFull = value
            End Set
        End Property

        Public Property IconFile() As String Implements ICodeCampInfo.IconFile
            Get
                Return Me.p_IconFile
            End Get
            Set(ByVal value As String)
                Me.p_IconFile = value
            End Set
        End Property

        Public Property MaximumCapacity() As Integer Implements ICodeCampInfo.MaximumCapacity
            Get
                Return Me.p_MaximumCapacity
            End Get
            Set(ByVal value As Integer)
                Me.p_MaximumCapacity = value
            End Set
        End Property

        Public Property ModuleId() As Integer Implements ICodeCampInfo.ModuleId
            Get
                Return Me.p_ModuleId
            End Get
            Set(ByVal value As Integer)
                Me.p_ModuleId = value
            End Set
        End Property

        Public Property NumberRegistered() As Integer Implements ICodeCampInfo.NumberRegistered
            Get
                Return Me.p_NumberRegistered
            End Get
            Set(ByVal value As Integer)
                Me.p_NumberRegistered = value
            End Set
        End Property

        Public Property RegistrationActive() As Boolean Implements ICodeCampInfo.RegistrationActive
            Get
                Return Me.p_RegistrationActive
            End Get
            Set(ByVal value As Boolean)
                Me.p_RegistrationActive = value
            End Set
        End Property

        Public Property RoleName() As String Implements ICodeCampInfo.RoleName
            Get
                Return Me.p_RoleName
            End Get
            Set(ByVal value As String)
                Me.p_RoleName = value
            End Set
        End Property

        Public Property ShowAuthor() As Boolean Implements ICodeCampInfo.ShowAuthor
            Get
                Return Me.p_ShowAuthor
            End Get
            Set(ByVal value As Boolean)
                Me.p_ShowAuthor = value
            End Set
        End Property

        Public Property ShowMicrosoftMVP() As Boolean Implements ICodeCampInfo.ShowMicrosoftMVP
            Get
                Return Me.p_ShowMicrosoftMVP
            End Get
            Set(ByVal value As Boolean)
                Me.p_ShowMicrosoftMVP = value
            End Set
        End Property

        Public Property ShowShirtSize() As Boolean Implements ICodeCampInfo.ShowShirtSize
            Get
                Return Me.p_ShowShirtSize
            End Get
            Set(ByVal value As Boolean)
                Me.p_ShowShirtSize = value
            End Set
        End Property

        Public Property Title() As String Implements ICodeCampInfo.Title
            Get
                Return Me.p_Title
            End Get
            Set(ByVal value As String)
                Me.p_Title = value
            End Set
        End Property

        Public Property WaitListRoleName() As String Implements ICodeCampInfo.WaitListRoleName
            Get
                Return Me.p_WaitListRoleName
            End Get
            Set(ByVal value As String)
                Me.p_WaitListRoleName = value
            End Set
        End Property

#End Region

        Public Sub New()
            ' do nothing
        End Sub

#Region " IHydratable Implementation "

        Public Property KeyID() As Integer Implements DotNetNuke.Entities.Modules.IHydratable.KeyID
            Get
                Return Me.p_CodeCampId
            End Get
            Set(ByVal value As Integer)
                Me.p_CodeCampId = value
            End Set
        End Property

        Public Sub Fill(ByVal dr As System.Data.IDataReader) Implements DotNetNuke.Entities.Modules.IHydratable.Fill
            Try
                While dr.Read
                    If Not dr.Item(AltTextField) Is Nothing Then
                        Me.p_AltText = dr.Item(AltTextField).ToString
                    End If
                    If Not dr.Item(BeginDateField) Is Nothing Then
                        If IsDate(dr.Item(BeginDateField)) Then
                            Me.p_BeginDate = Date.Parse(dr.Item(BeginDateField).ToString)
                        End If
                    End If
                    If Not dr.Item(CodeCampIdField) Is Nothing Then
                        Me.p_CodeCampId = Integer.Parse(dr.Item(CodeCampIdField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(CreatedByDateField) Is Nothing Then
                        If IsDate(dr.Item(CreatedByDateField)) Then
                            Me.p_CreatedByDate = Date.Parse(dr.Item(CreatedByDateField).ToString)
                        End If
                    End If
                    If Not dr.Item(CreatedByUserField) Is Nothing Then
                        Me.p_CreatedByUser = Integer.Parse(dr.Item(CreatedByUserField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(DescriptionField) Is Nothing Then
                        Me.p_Description = dr.Item(DescriptionField).ToString
                    End If
                    If Not dr.Item(EndDateField) Is Nothing Then
                        If IsDate(dr.Item(EndDateField)) Then
                            Me.p_EndDate = Date.Parse(dr.Item(EndDateField).ToString)
                        End If
                    End If
                    If Not dr.Item(EventFullField) Is Nothing Then
                        Me.p_EventFull = Boolean.Parse(dr.Item(EventFullField).ToString)
                    End If
                    If Not dr.Item(IconFileField) Is Nothing Then
                        Me.p_IconFile = dr.Item(IconFileField).ToString
                    End If
                    If Not dr.Item(MaximumCapacityField) Is Nothing Then
                        Me.p_MaximumCapacity = Integer.Parse(dr.Item(MaximumCapacityField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(ModuleIdField) Is Nothing Then
                        Me.p_ModuleId = Integer.Parse(dr.Item(ModuleIdField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(NumberRegisteredField) Is Nothing Then
                        Me.p_NumberRegistered = Integer.Parse(dr.Item(NumberRegisteredField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(RegistrationActiveField) Is Nothing Then
                        Me.p_RegistrationActive = Boolean.Parse(dr.Item(RegistrationActiveField).ToString)
                    End If
                    If Not dr.Item(RoleNameField) Is Nothing Then
                        Me.p_RoleName = dr.Item(RoleNameField).ToString
                    End If
                    If Not dr.Item(ShowAuthorField) Is Nothing Then
                        Me.p_ShowAuthor = Boolean.Parse(dr.Item(ShowAuthorField).ToString)
                    End If
                    If Not dr.Item(ShowMicrosoftMVPField) Is Nothing Then
                        Me.p_ShowMicrosoftMVP = Boolean.Parse(dr.Item(ShowMicrosoftMVPField).ToString)
                    End If
                    If Not dr.Item(ShowShirtSizeField) Is Nothing Then
                        Me.p_ShowShirtSize = Boolean.Parse(dr.Item(ShowShirtSizeField).ToString)
                    End If
                    If Not dr.Item(TitleField) Is Nothing Then
                        Me.p_Title = dr.Item(TitleField).ToString
                    End If
                    If Not dr.Item(WaitListRoleNameField) Is Nothing Then
                        Me.p_WaitListRoleName = dr.Item(WaitListRoleNameField).ToString
                    End If
                End While
            Catch ex As Exception
                LogException(ex)
            Finally
                If Not dr.IsClosed Then
                    dr.Close()
                End If
            End Try
        End Sub

#End Region

    End Class

End Namespace